package com.xinxing.city.recovery.adapter;


import com.xinxing.city.recovery.R;
import com.xinxing.city.recovery.entitys.MenuBean;
import com.zhpan.bannerview.BaseBannerAdapter;
import com.zhpan.bannerview.BaseViewHolder;

public class SimpleAdapter extends BaseBannerAdapter<MenuBean> {
    private int selectedPosition = 0;
    private BaseViewHolder<MenuBean> holder;

    @Override
    public void bindData(BaseViewHolder<MenuBean> hol, MenuBean data, int position, int pageSize) {
        holder = hol;
        holder.setImageResource(R.id.banner_image, data.getImage());
        //holder.setText(R.id.banner_text, data.getTitle());
        if (selectedPosition == position) {
            holder.itemView.setScaleX(2.6f);
            holder.itemView.setScaleY(2.6f);
            holder.itemView.setZ(6);
        } else if (selectedPosition == (position + 1) ||  selectedPosition == (position - 1) ||  (selectedPosition == 0 && position == (pageSize - 1)) || (selectedPosition == (pageSize - 1) && position == 0)) {
            holder.itemView.setScaleX(2f);
            holder.itemView.setScaleY(2f);
            holder.itemView.setZ(4);
        } else {
            holder.itemView.setScaleX(1.7f);
            holder.itemView.setScaleY(1.7f);
            holder.itemView.setZ(2);
        }
    }

    public void setSelectedPosition(int position) {
        selectedPosition = position;

        notifyDataSetChanged();
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.item_custom_view;
    }
}

